package(default_visibility = ["//:__subpackages__"])

licenses(["notice"])

cc_library(
    name = "raw_jwt",
    srcs = ["raw_jwt.cc"],
    hdrs = ["raw_jwt.h"],
    include_prefix = "tink/jwt",
    visibility = ["//visibility:public"],
    deps = [
        "//jwt/internal:json_util",
        "//util:status",
        "//util:statusor",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/time",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_library(
    name = "verified_jwt",
    srcs = ["verified_jwt.cc"],
    hdrs = ["verified_jwt.h"],
    include_prefix = "tink/jwt",
    visibility = ["//visibility:public"],
    deps = [
        ":raw_jwt",
        "//jwt/internal:json_util",
        "//util:status",
        "//util:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/time",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_library(
    name = "jwt_validator",
    srcs = ["jwt_validator.cc"],
    hdrs = ["jwt_validator.h"],
    include_prefix = "tink/jwt",
    visibility = ["//visibility:public"],
    deps = [
        ":raw_jwt",
        "//util:status",
        "//util:statusor",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
    ],
)

cc_library(
    name = "jwt_mac",
    hdrs = ["jwt_mac.h"],
    include_prefix = "tink/jwt",
    visibility = ["//visibility:public"],
    deps = [
        ":jwt_validator",
        ":raw_jwt",
        ":verified_jwt",
        "//util:status",
        "//util:statusor",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "jwt_public_key_sign",
    hdrs = ["jwt_public_key_sign.h"],
    include_prefix = "tink/jwt",
    visibility = ["//visibility:public"],
    deps = [
        ":raw_jwt",
        "//util:status",
        "//util:statusor",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "jwt_public_key_verify",
    hdrs = ["jwt_public_key_verify.h"],
    include_prefix = "tink/jwt",
    visibility = ["//visibility:public"],
    deps = [
        ":jwt_validator",
        ":verified_jwt",
        "//util:status",
        "//util:statusor",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "jwt_mac_config",
    srcs = ["jwt_mac_config.cc"],
    hdrs = ["jwt_mac_config.h"],
    include_prefix = "tink/jwt",
    visibility = ["//visibility:public"],
    deps = [
        "//:registry",
        "//config:config_util",
        "//config:tink_fips",
        "//jwt/internal:jwt_hmac_key_manager",
        "//jwt/internal:jwt_mac_wrapper",
        "//proto:config_cc_proto",
        "//util:status",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/memory",
    ],
)

cc_library(
    name = "jwt_key_templates",
    srcs = ["jwt_key_templates.cc"],
    hdrs = ["jwt_key_templates.h"],
    include_prefix = "tink/jwt",
    visibility = ["//visibility:public"],
    deps = [
        "//internal:bn_util",
        "//internal:ssl_unique_ptr",
        "//proto:common_cc_proto",
        "//proto:jwt_ecdsa_cc_proto",
        "//proto:jwt_hmac_cc_proto",
        "//proto:jwt_rsa_ssa_pkcs1_cc_proto",
        "//proto:jwt_rsa_ssa_pss_cc_proto",
        "//proto:tink_cc_proto",
        "//util:statusor",
        "@boringssl//:crypto",
    ],
)

cc_library(
    name = "jwk_set_converter",
    srcs = ["jwk_set_converter.cc"],
    hdrs = ["jwk_set_converter.h"],
    include_prefix = "tink/jwt",
    visibility = ["//visibility:public"],
    deps = [
        "//:binary_keyset_writer",
        "//:keyset_handle",
        "//internal:ec_util",
        "//internal:ssl_unique_ptr",
        "//jwt/internal:json_util",
        "//jwt/internal:jwt_format",
        "//proto:jwt_ecdsa_cc_proto",
        "//proto:jwt_rsa_ssa_pkcs1_cc_proto",
        "//proto:jwt_rsa_ssa_pss_cc_proto",
        "//proto:tink_cc_proto",
        "//subtle:common_enums",
        "//util:keyset_util",
        "//util:status",
        "//util:statusor",
        "@boringssl//:crypto",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:optional",
    ],
)

cc_library(
    name = "jwt_signature_config",
    srcs = ["jwt_signature_config.cc"],
    hdrs = ["jwt_signature_config.h"],
    include_prefix = "tink/jwt",
    visibility = ["//visibility:public"],
    deps = [
        "//:registry",
        "//config:config_util",
        "//config:tink_fips",
        "//jwt/internal:jwt_ecdsa_sign_key_manager",
        "//jwt/internal:jwt_ecdsa_verify_key_manager",
        "//jwt/internal:jwt_public_key_sign_wrapper",
        "//jwt/internal:jwt_public_key_verify_wrapper",
        "//jwt/internal:jwt_rsa_ssa_pkcs1_sign_key_manager",
        "//jwt/internal:jwt_rsa_ssa_pkcs1_verify_key_manager",
        "//jwt/internal:jwt_rsa_ssa_pss_sign_key_manager",
        "//jwt/internal:jwt_rsa_ssa_pss_verify_key_manager",
        "//proto:config_cc_proto",
        "//util:status",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/memory",
    ],
)

# tests

cc_test(
    name = "raw_jwt_test",
    size = "small",
    srcs = ["raw_jwt_test.cc"],
    deps = [
        ":raw_jwt",
        "//util:test_matchers",
        "//util:test_util",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "verified_jwt_test",
    size = "small",
    srcs = ["verified_jwt_test.cc"],
    deps = [
        ":jwt_mac",
        ":jwt_validator",
        ":raw_jwt",
        ":verified_jwt",
        "//jwt/internal:jwt_mac_impl",
        "//jwt/internal:jwt_mac_internal",
        "//subtle:hmac_boringssl",
        "//util:constants",
        "//util:enums",
        "//util:errors",
        "//util:protobuf_helper",
        "//util:secret_data",
        "//util:test_matchers",
        "//util:test_util",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "jwt_validator_test",
    size = "small",
    srcs = ["jwt_validator_test.cc"],
    deps = [
        ":jwt_validator",
        ":raw_jwt",
        "//util:test_matchers",
        "//util:test_util",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "jwt_key_templates_test",
    srcs = ["jwt_key_templates_test.cc"],
    deps = [
        ":jwt_key_templates",
        ":jwt_mac",
        ":jwt_mac_config",
        ":jwt_public_key_sign",
        ":jwt_public_key_verify",
        ":jwt_signature_config",
        ":jwt_validator",
        ":raw_jwt",
        ":verified_jwt",
        "//util:status",
        "//util:test_matchers",
        "//util:test_util",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "jwk_set_converter_test",
    srcs = ["jwk_set_converter_test.cc"],
    deps = [
        ":jwk_set_converter",
        ":jwt_public_key_sign",
        ":jwt_public_key_verify",
        ":jwt_signature_config",
        ":jwt_validator",
        ":verified_jwt",
        "//:cleartext_keyset_handle",
        "//:json_keyset_reader",
        "//:keyset_handle",
        "//:keyset_reader",
        "//jwt/internal:json_util",
        "//proto:ecdsa_cc_proto",
        "//proto:jwt_ecdsa_cc_proto",
        "//proto:jwt_rsa_ssa_pkcs1_cc_proto",
        "//util:status",
        "//util:statusor",
        "//util:test_matchers",
        "@boringssl//:crypto",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_test(
    name = "jwt_mac_config_test",
    srcs = ["jwt_mac_config_test.cc"],
    tags = ["fips"],
    deps = [
        ":jwt_key_templates",
        ":jwt_mac_config",
        "//:keyset_handle",
        "//:registry",
        "//internal:fips_utils",
        "//util:test_matchers",
        "@boringssl//:crypto",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_test(
    name = "jwt_signature_config_test",
    srcs = ["jwt_signature_config_test.cc"],
    tags = ["fips"],
    deps = [
        ":jwt_key_templates",
        ":jwt_signature_config",
        "//:keyset_handle",
        "//:registry",
        "//internal:fips_utils",
        "//util:test_matchers",
        "@boringssl//:crypto",
        "@com_google_googletest//:gtest_main",
    ],
)
